package com.gsn.poker.play;

import java.util.List;

import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.scenes.scene2d.ui.ClickListener;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.gsn.desktop.engine.ActorUtility;
import com.gsn.engine.myplay.GsnGame;

public class CongTruTienGroup extends Group {
	List<AtlasRegion> nums;
	Group number;
	float standardTime;
	float remainTime;
	boolean pause = false;
	Image bg;
	TextureRegion bgRun;
	TextureRegion bgPause;		
	public void setClickListener(ClickListener listener) {
		bg.setClickListener(listener);
	}
	
	public static Group convertNum(long time, List<AtlasRegion> numsCong, List<AtlasRegion> numsTru, AtlasRegion daucong, AtlasRegion dautru, AtlasRegion dauchamcong, AtlasRegion dauchamtru){
		Group group = new Group();
		group.transform = GsnGame.transform;
		group.height = numsCong.get(0).getRegionHeight();
		String str = ActorUtility.formatNumber(Math.abs(time));		
		Image tmp;
		if (time >= 0){
			tmp = new Image(daucong);			
		} else 
			tmp = new Image(dautru);
		tmp.y = group.height / 2 - tmp.height / 2;
		group.width += tmp.width;
		group.addActor(tmp);		
		for (int i = 0; i < str.length(); i++){
			if ( str.charAt(i) != '.'){
				if (time >= 0)
					tmp = new Image((TextureRegion) (numsCong.get(str.charAt(i) - '0')));
				else 
					tmp = new Image((TextureRegion) (numsTru.get(str.charAt(i) - '0')));				
			}
			else {
				if (time >= 0)
					tmp = new Image(dauchamcong);
				else 
					tmp = new Image(dauchamtru);				
			}
			tmp.x = group.width;
			group.width += tmp.width;
			group.addActor(tmp);
		}
		return group;
	}	
	
}
